<?php
class M_Country extends Apps_Db_Table_Abstract {
    protected $_name = 'country';

    public function listCountry() {
        $q = $this->_db
                  ->select()
                  ->from('country', null)
                  ->where('country.status =? ', 1)
                  ->order('sorting_number ASC')
                  ->columns(array('id' => 'country.id'));

        if($this->getLang() == 'en') {
            $q->columns(array('name' => 'country.en_name'));
        } else $q->columns(array('name' => 'country.name'));

        return $q;
    }

    public function getCountryById($id) {
        $q = $this->_db
                    ->select()
                    ->from($this->_name, null)
                    ->where('country.id =? ', $id)
                    ->columns(array('id' => 'country.id'));

        if($this->getLang() == 'en') {
            $q->columns(array('name' => 'country.en_name'));
        } else $q->columns(array('name' => 'country.name'));
        
        return $q;
    }
}